# 猜大小游戏
# . 预备知识:random模块和randomint
# . 模拟色子: 随机生成3个1~6的数
# . 三个色子和在3~10=> 小，11~18=>大
# . 用户在键盘输入猜"大"或"小"，一轮结果，给出结果
# . 可无限玩，直到用户输入exit,结束后，统计用户玩的次数，胜率
# . 扩展:增加金豆，进场默认1000金豆，猜对赢100金豆，猜错输100金豆，金豆低于100不能玩
# 扩展：增加礼品
import random
#random_result(sweet=0,gold_bean=1000,win=0,lose=0,i=0,result1="小",result2="大")
def random_result(gold_bean:int,sweet:int,result1:str,result2:str,win:int,lose:int,i:int):
    while True:
        Random_number1 = random.randint(1, 6)
        Random_number2 = random.randint(1, 6)
        Random_number3 = random.randint(1, 6)
        Random_sum_number = Random_number1 + Random_number2 + Random_number3
        guess_result = input("请输入您的猜结果：")
        win_rate = 0
        if guess_result == "exit":
            print(f"您猜了{i}次，赢了{win}次，输了{lose}次，胜率为{win_rate}，游戏结束")
            break
        if gold_bean < 100:
            print(f"您猜了{i}次，赢了{win}次，输了{lose}次，胜率为{win_rate}，游戏结束")
            break

        result = "小" if Random_sum_number >=3 and Random_sum_number <= 10 else "大"
        # if Random_sum_number >=3 and Random_sum_number <= 10
        if guess_result == result:
            print(f"恭喜你，猜对了!结果是{result1}的")
            gold_bean += 100
            sweet += 1
            win += 1
            print(f"您当前拥有的金豆数为{gold_bean}个")
            print(f"您获得一件礼品数,礼品数是{sweet}个")
            i = i + 1
            win_rate = win / (win + lose)
        else:
            gold_bean -= 100
            lose += 1
            print("对不起，你猜错了！")
            print(f"您当前拥有的金豆数为{gold_bean}个")
            print(f"您没有获得礼品数,礼品数是{sweet}个")
            i = i + 1
            win_rate = win / (win + lose)

        # if Random_sum_number >=3 and Random_sum_number <= 10:
        #     if guess_result == result1:
        #         print(f"恭喜你，猜对了!结果是{result1}的")
        #         gold_bean+=100
        #         sweet+=1
        #         win+=1
        #         print(f"您当前拥有的金豆数为{gold_bean}个")
        #         print(f"您获得一件礼品数,礼品数是{sweet}个")
        #         i=i+1
        #         win_rate = win/(win+lose)
        #     else:
        #         gold_bean-=100
        #         lose += 1
        #         print("对不起，你猜错了！")
        #         print(f"您当前拥有的金豆数为{gold_bean}个")
        #         print(f"您没有获得礼品数,礼品数是{sweet}个")
        #         i=i+1
        #         win_rate = win/(win+lose)
        # if Random_sum_number >=11 and Random_sum_number <= 18:
        #     if guess_result == result2:
        #         print(f"恭喜你，猜对了!结果是{result2}的")
        #         gold_bean+=100
        #         sweet+=1
        #         win += 1
        #         print(f"您当前拥有的金豆数为{gold_bean}个")
        #         print(f"您获得一件礼品数,礼品数是{sweet}个")
        #         i=i+1
        #         win_rate = win/(win+lose)
        #     else:
        #         gold_bean-=100
        #         lose += 1
        #         print("对不起，你猜错了！")
        #         print(f"您当前拥有的金豆数为{gold_bean}个")
        #         print(f"您没有获得礼品数,礼品数是{sweet}个")
        #         i=i+1
        #         win_rate = win/(win+lose)
random_result(sweet=0,gold_bean=1000,win=0,lose=0,i=0,result1="小",result2="大")



